using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Loading.Models;

namespace Loading.Controllers
{   
    public class CartrigeRecipiesController : Controller
    {
		private readonly ICartrigeRecipieRepository cartrigerecipieRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public CartrigeRecipiesController() : this(new CartrigeRecipieRepository())
        {
        }

        public CartrigeRecipiesController(ICartrigeRecipieRepository cartrigerecipieRepository)
        {
			this.cartrigerecipieRepository = cartrigerecipieRepository;
        }

        //
        // GET: /CartrigeRecipies/

        public ViewResult Index()
        {
            return View(cartrigerecipieRepository.All);
        }

        //
        // GET: /CartrigeRecipies/Details/5

        public ViewResult Details(int id)
        {
            return View(cartrigerecipieRepository.Find(id));
        }

        //
        // GET: /CartrigeRecipies/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /CartrigeRecipies/Create

        [HttpPost]
        public ActionResult Create(CartrigeRecipie cartrigerecipie)
        {
            if (ModelState.IsValid) {
                cartrigerecipieRepository.InsertOrUpdate(cartrigerecipie);
                cartrigerecipieRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /CartrigeRecipies/Edit/5
 
        public ActionResult Edit(int id)
        {
             return View(cartrigerecipieRepository.Find(id));
        }

        //
        // POST: /CartrigeRecipies/Edit/5

        [HttpPost]
        public ActionResult Edit(CartrigeRecipie cartrigerecipie)
        {
            if (ModelState.IsValid) {
                cartrigerecipieRepository.InsertOrUpdate(cartrigerecipie);
                cartrigerecipieRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /CartrigeRecipies/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View(cartrigerecipieRepository.Find(id));
        }

        //
        // POST: /CartrigeRecipies/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            cartrigerecipieRepository.Delete(id);
            cartrigerecipieRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

